Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Add lazy initialization to SerialController #57

Merged
merged 1 commit into from
Nov 9, 2018

Conversation

josesimoes
Copy link
Member

Description

  • Add lazy initialization to SerialController.

Motivation and Context

  • Make sure that the variables do exist when being used. Using the previous code was causing issues because on occasions the types could still be unresolved.
  • Addresses GPIO NULL Reference Home#383.

How Has This Been Tested?

Screenshots

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: José Simões jose.simoes@eclo.solutions

@nfbot
Copy link
Member

nfbot commented Nov 9, 2018

Hi @josesimoes,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

Copy link
Member

@steffalk steffalk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. If lock() is expensive, you could extend the pattern to: if (s_instance != null) {return s_instance;} else {… the code you provided so far, that is the lock() {...} block). That way, if many clients want to have the instance, unnecessary lock() operations would be saved.

Signed-off-by: José Simões <jose.simoes@eclo.solutions>
@josesimoes josesimoes merged commit 3b9719b into nanoframework:develop Nov 9, 2018
@josesimoes josesimoes deleted the work-controller branch November 9, 2018 15:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants