Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gtest): Use AuxiliaryTaskPool for current scheduled ops on gtest #4154

Merged
merged 9 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/auxiliary/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub type AuxiliaryMailbox<MailboxCallbacks> = MailboxImpl<
MailboxCallbacks,
MailboxKeyGen<ProgramId>,
>;

/// Type represents message stored in the mailbox.
pub type MailboxedMessage = UserStoredMessage;

Expand Down Expand Up @@ -68,6 +67,7 @@ impl AuxiliaryDoubleStorageWrap for MailboxStorageWrap {
MAILBOX_STORAGE.with_borrow_mut(f)
}
}

/// An implementor of the error returned from calling `Mailbox` trait functions.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum MailboxErrorImpl {
Expand Down
2 changes: 1 addition & 1 deletion common/src/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

pub mod gas_provider;
pub mod mailbox;
pub mod taskpool;
pub mod task_pool;

use crate::storage::{
Counted, CountedByKey, DoubleMapStorage, GetFirstPos, GetSecondPos, IterableByKeyMap,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
//! Auxiliary implementation of the taskpool.
// This file is part of Gear.

// Copyright (C) 2024 Gear Technologies Inc.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Auxiliary implementation of the task pool.

use super::{AuxiliaryDoubleStorageWrap, BlockNumber, DoubleBTreeMap};
use crate::scheduler::{ScheduledTask, TaskPoolImpl};
use gear_core::ids::ProgramId;
use std::cell::RefCell;

/// Task pool implementation that can be used in a native, non-wasm runtimes.
pub type AuxiliaryTaskpool<TaskPoolCallbacks> = TaskPoolImpl<
TaskPoolStorageWrap,
ScheduledTask<ProgramId>,
Expand All @@ -17,6 +36,7 @@ std::thread_local! {
pub(crate) static TASKPOOL_STORAGE: RefCell<DoubleBTreeMap<BlockNumber, ScheduledTask<ProgramId>, ()>> = const { RefCell::new(DoubleBTreeMap::new()) };
}

/// `TaskPool` double storage map manager
pub struct TaskPoolStorageWrap;

impl AuxiliaryDoubleStorageWrap for TaskPoolStorageWrap {
Expand All @@ -39,6 +59,7 @@ impl AuxiliaryDoubleStorageWrap for TaskPoolStorageWrap {
}
}

/// An implementor of the error returned from calling `TaskPool` trait functions.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum TaskPoolErrorImpl {
/// Occurs when given task already exists in task pool.
Expand Down
2 changes: 1 addition & 1 deletion gtest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ mod mailbox;
mod manager;
mod program;
mod system;
mod taskpool;
mod task_pool;

pub use crate::log::{BlockRunResult, CoreLog, Log};
pub use codec;
Expand Down
Loading
Loading